package com.hspedu.poly_.dynamic;

/**
 * @author 谷其昊
 * @version 1.0
 * @date 2022/1/22
 * @time 19:50
 */
public class DynamicBinding {
    public static void main(String[] args) {
        A a = new B();
        System.out.println(a.i);
        B b = new B();
        System.out.println(b.ii);
        System.out.println(a.sum());
        System.out.println(a.sum1());
    }
}

class A {
    public int i = 10;
    int ii = 30;
    public int sum(){
        return getI()+10;
    }

    public int sum1(){
        return this.i+10;
    }

    public int getI(){
        return i;
    }
}

class B extends A{
    public int i = 20;
    int ii = 100;

    @Override
    public int getI(){
        return i;
    }
}
